<!--
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * date: 2021-09-08 20:20:43
 * @LastEditors: Sam
 * @LastEditTime: 2021-12-09 10:38:33
-->
{include file="common/public/header"}
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-card">
                <div class="layui-card-header">搜索</div>
                <div class="layui-card-body">
                    <form class="layui-search layui-form"><div class="layui-col-md3"><label>关键字</label><div class="layui-input-inline"><input type="text" class="layui-input" name="title" value="" placeholder="请输入题目名称搜索"  ></div></div><div class="layui-col-md3 layui-search-submit"><div class="layui-input-inline"><button class="layui-btn layui-btn-normal layui-btn-sm" type="button" onclick="table_search(this)"><i class="layui-icon layui-icon-search"></i> 搜索</button></div></div><div class="layui-clear"></div></form></div
                </div>
            </div>
            
        </div>
    </div>
    
<div class="layui-fluid">
  
    <div class="layui-row layui-col-space15">
   
        <div class="layui-card">
            {if condition="!$frame"}<div class="layui-card-header">{$page_title}</div>{/if}
            <div class="layui-card-body">
                
                <table id="table"></table>
                <script type="text/html" id="barDemo">
                    {:table_button('admin/Survey/survey_theme_add',"添加","frame")}
                    {:table_button('admin/Survey/down_temp',"下载模板","url")}
                </script>
                <script type="text/html" id="toolbar_row">
                    {:table_button('admin/Survey/survey_theme_edit',"编辑","frame")}
                    {:table_button('admin/Survey/survey_theme_del',"删除","confirm")}
                    <a class="layui-btn layui-btn-xs import_excell" value="{{d.id}}"> <i class="layui-icon layui-icon-export"></i> 导入</a>
                </script>
            </div>
        </div>
    </div>
</div>
{include file="common/public/footer" /}
{include file="common/public/table" /}
<script>
    layui.use(['index', 'form', 'table','upload'], function(){
        var uploadParam = {};
        var $       = layui.$;
        var table   = layui.table;
        var upload   = layui.upload;
        table.render(
            {
                "limit":20,
                "limits":[10,15,20,30,40,50,60,70,80,90,100],
                "elem":"#table",
                "height":"full",
                "url":"{:url('admin/survey/survey_theme')}",
                "page":true,
                "method":"POST",
                "done":function(res, curr, count){
                    var uploadInst = upload.render({
                        elem: '.import_excell' //绑定元素
                        ,url: "{:url('admin/survey/import')}" //上传接口
                        ,accept:'file'
                        ,exts:"csv"
                        ,data:{
                            'id' : function(){
                                return uploadParam.id
                            }
                        }
                        ,before: function(obj){ //obj包含信息，跟choose回调完全一致。在传值之前先获取id
                            var tableElem = this.item;
                                uploadParam.id = tableElem.attr('value');
                               var load =  layer.load();
                            }
                        ,done: function(res){
                            //上传完毕回调
                            if(res.code){
                                layer.alert(res.msg,{icon:1,title:'提示'},function(){
                                    layer.msg('导入成功');
                                    layer.closeAll();
                                });
                               
                            }
                                
                        },
                        error:function(){
                            layer.alert('导入失败请重试',{icon:2,title:'错误'});
                                return;
                        }
                    });
                },
                "cols":
                [[
                    {"type":"checkbox"}
                    ,{"field":"id","title":"编号","align":"center"},
                    {"field":"title","title":"标题","align":"center"}
                    ,{"field":"sort","title":"排序","align":"center"}
                    ,{"title":"操作","width":200,"fixed":"right","toolbar":"#toolbar_row"}
                ]],
                "toolbar":"#barDemo"
               });
});
</script>